﻿using System;
using System.Collections.Generic;
using System.Text;

namespace net.xBei.Helper {
    /// <summary>
    /// 长度
    /// </summary>
    public static class UnitConverterHelper {
        #region 长度单位
        //1 英寸 = 2.54 厘米（cm）= 25.4 毫米（mm）[1]
        /// <summary>
        /// 毫米（mm）=>英寸（in）
        /// </summary>
        /// <param name="millimeter"></param>
        /// <returns></returns>
        public static decimal MillimeterToInch(this decimal millimeter) => millimeter / 0.2539999918m;
        /// <summary>
        /// 厘米（cm）=>英寸（in）
        /// </summary>
        /// <param name="centimeter"></param>
        /// <returns></returns>
        public static decimal CentimeterToInch(this decimal centimeter) => centimeter / 2.539999918m;
        /// <summary>
        /// 英寸（in）=>厘米（cm）
        /// </summary>
        /// <param name="inch"></param>
        /// <returns></returns>
        public static decimal InchToCentimeter(this decimal inch) => inch * 2.539999918m;
        /// <summary>
        /// 米（m）=>英寸（in）
        /// </summary>
        /// <param name="meter"></param>
        /// <returns></returns>
        public static decimal MeterToInch(this decimal meter) => meter / 25.39999918m;
        #endregion
        #region 质量（重量）单位
        /// <summary>
        /// 克=》磅（lb）
        /// <link>https://zh.wikipedia.org/wiki/%E7%A3%85</link> 
        /// </summary>
        /// <param name="gram"></param>
        /// <returns></returns>
        public static decimal GramToPound(this decimal gram) => gram / 453.59237m;
        /// <summary>
        /// 千克=》磅（lb）
        /// </summary>
        /// <param name="kg"></param>
        /// <returns></returns>
        public static decimal KilogramToPound(this decimal kg) => (kg * 1000) / 453.59237m;
        /// <summary>
        /// 磅（lb）=》克
        /// </summary>
        /// <param name="lb"></param>
        /// <returns></returns>
        public static decimal PoundToGram(this decimal lb) => lb * 453.59237m;
        /// <summary>
        /// 磅（lb）=》千克
        /// </summary>
        /// <param name="lb"></param>
        /// <returns></returns>
        public static decimal PoundToKilogram(this decimal lb) => lb * 0.45359237m;
        #endregion
    }
}
